<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //weakset :弱引用set数据  方法比set少  性能更好
      //WeakSet 的成员只能是对象，而不能是其他类型的值
      // let set = new WeakSet();
      // let obj = { hello: "你好" };
      // set.add(obj);
      // console.log(set);
      // console.log(set.has(obj));
      // console.log(set.delete(obj));
      // console.log(set);

      //WeakMap : 弱引用类型的map数据
      //只能使用对象类型作为键名
      let myMap = new Map();
      let map = new WeakMap();
      let obj = { hello: "你好" };
      map.set(obj, "张三");
      console.log(map);
      console.log(map.has(obj));
      console.log(map.get(obj));
      map.delete(obj);
      console.log(map);
      console.log(myMap);
    </script>
  </body>
</html>
